package com.hxzy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxzy.common.vo.R;
import com.hxzy.config.security.SecurityUtil;
import com.hxzy.dto.PageDTO;
import com.hxzy.entity.MallCarousel;
import com.hxzy.mapper.MallCarouselMapper;
import com.hxzy.service.MallCarouselService;
import com.hxzy.vo.AdminLoginVO;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

/**
 * 首页轮播图
 */
@Service
public class MallCarouselServiceImpl extends ServiceImpl<MallCarouselMapper, MallCarousel> implements MallCarouselService {
    @Override
    public  IPage<MallCarousel> getData(PageDTO pageDTO) {
        IPage<MallCarousel> carouselIPage = new Page<>(pageDTO.getPage(),pageDTO.getSize());
        QueryWrapper<MallCarousel> queryWrapper = new QueryWrapper<MallCarousel>();
        queryWrapper.eq("IS_DELETED",0);
        IPage<MallCarousel> iPage = this.baseMapper.selectPage(carouselIPage, queryWrapper);
        return  iPage ;
    }

    @Override
    public boolean updateIsDeletedByCarouselId(Long[] deleteIds) {
        int  count=this.baseMapper.updateIsDeletedByCarouselId(deleteIds, SecurityUtil.getLoginName());
        return  count==deleteIds.length;
    }


}
